

var player = new Vue({
    el: '#player',
    data: {
        // 查询关键字
        query: '许嵩',
        songList: [],
        musicUrl: [],
        isPlay: false,
        isShow: false,
        coverUrl: [],
        Comment: [],
        mvUrl: [],
        showVideo: false
    },
    methods: {
        searchMusic: function () {
            if (this.query == 0) {
                return
            }
            let that = this;
            axios.get("https://autumnfish.cn/search?keywords=" + this.query).then(function (response) {
                that.songList = response.data.result.songs;

            }, function (err) {
                console.log(err);
            })
            // 清空搜索
            this.query = ''

        },
        playMusic: function (musicID) {
            // 获取歌曲url
            let that = this;
            axios.get("https://autumnfish.cn/song/url?id=" + musicID).then(function (response) {
                that.musicUrl = response.data.data[0].url;
            }, function (err) {

            });

            // 获取歌曲封面
            axios.get("https://autumnfish.cn/song/detail?ids=" + musicID).then(response => {
                console.log(response);
                this.coverUrl = response.data.songs[0].al.picUrl
                console.log(this.coverUrl);
            }, function (err) {
            });

            //获取评论
            axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicID).then(response => {
                console.log(response);
                this.Comment = response.data.hotComments

            }, function (err) {
            });

        },
        // audio的play事件
        play() {
            console.log('play');
            this.isPlay = true
        },
        // audio的pause事件
        pause() {
            console.log('pause');
            this.isPlay = false
        },
        // 播放mv
        playMv: function (mvid) {
            axios.get("https://autumnfish.cn/mv/url?id=" + mvid).then(response => {
                this.showVideo = true
                // 暂停歌曲播放
                this.$refs.audio.pause()
                this.mvUrl = response.data.data.url
            }), function (err) {

            }
        },
        closeMv() {
            this.showVideo = false
            this.$refs.video.pause()
        }

    }
})
